function plus(num) {
    var sum = 0;

    sum += num
    f = function(num) {
        sum += num
        return f
    }
    f.toString = function() {
        return sum
    }
    return f

}

console.log(plus(2)(3).toString())
console.log(plus(2)(3)(4).toString())
console.log(plus(2)(3)(5)(6).toString())
console.log(plus(2).toString())